import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../store'
import  from ''
Vue.use(VueRouter)

const routes = [{
    path: "",
    redirect: "/homepage"
  },
  {
    path: '/home',
    name: 'home',
    component: () => import( /* webpackChunkName: "about" */ '../views/Home.vue'),
    children: [{
        path: '/sweep',
        name: 'sweep',
        component: () => import( /* webpackChunkName: "about" */ '../views/sweep.vue'),
      },
      {
        path: '/collect',
        name: 'collect',
        component: () => import( /* webpackChunkName: "about" */ '../components/collect.vue'),
      },
      {
        path: '/order',
        name: 'order',
        component: () => import( /* webpackChunkName: "about" */ '../components/order.vue'),
      },
      {
        path: '/shoppingCart',
        name: 'shoppingCart',
        component: () => import( /* webpackChunkName: "about" */ '../components/shoppingCart.vue'),
      },
      {
        path: '/MyErrow',
        name: 'MyErrow',
        component: () => import( /* webpackChunkName: "about" */ '../views/MyErrow.vue'),
      },
      {
        path: '/xq',
        name: 'xq',
        component: () => import( /* webpackChunkName: "about" */ '../components/Particulars.vue'),
      },
      {
        path: '/homepage',
        name: 'homepage',
        component: () => import( /* webpackChunkName: "about" */ '../components/homepage.vue'),
      },
      {
        path: '/shopping',
        name: 'shopping',
        component: () => import( /* webpackChunkName: "about" */ '../components/shopping.vue'),
      },
      {
        path: '/about',
        name: 'about',
        component: () => import( /* webpackChunkName: "about" */ '../components/about.vue'),
      },
    ],

  },
  {
    path: '/login',
    name: 'login',
    component: () => import( /* webpackChunkName: "about" */ '../views/login.vue'),
  },
  {
    path: '/register',
    name: 'register',
    component: () => import( /* webpackChunkName: "about" */ '../views/register.vue'),
  },
]




const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
};
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
// router.beforeEach((to,from,next)=>{
//   if(to.path == '/order'||to.path=='shoppingcart'||to.path=='collect'){
//      if(store.state.token){
//         next();
//      }
//   }else{
//     next(from.path+"?dialogVisibles=true");
//   }
//   next(true)
// })

export default router